home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr10
/
delcol10.zip
/
DELCOL.C
next >
Wrap
C/C++ Source or Header
|
1993-06-09
|
3KB
|
83 lines
/*-----------------------DELCOL.EXE--------------By Steve Elliott---10-3-92-*/
#include "stdio.h"
#include "stdlib.h"
void directions(void);
unsigned int linecount = 0;
main(int argc, char *argv[]){
FILE *fp1;
FILE *fp2;
char *c;
char oneword[100];
char infile[14];
char outfile[14];
char ctmp[4];
char atmp[4];
unsigned int xcol = 1;
unsigned int xamount = 0;
unsigned int index;
if(argc < 4)directions();
if(argc < 4){do{
printf("Enter input name -> ");
scanf("%s",infile); /* read the desired name */
fp1 = fopen(infile,"r");
}while(fp1 == 0);
printf("Enter output name -> ");
scanf("%s",outfile); /* read the desired name */
fp2 = fopen(outfile,"a");
printf("Enter the first column to delete #? ");
scanf("%s",ctmp); /* read the desired column to delete*/
xcol = atoi(ctmp);
printf("Enter the last column to delete #? ");
scanf("%s",atmp); /* read the desired columns from xcol to delete */
xamount = atoi(atmp);
if(xamount < xcol)xamount = xcol;
}
else { fp1 = fopen(argv[1],"r"); fp2 = fopen(argv[2],"a");
xcol = atoi(argv[3]);
if(argc == 3)xamount = xcol;
else { xamount = atoi(argv[4]);
if(xamount < xcol)xamount = xcol;}
}
xcol--;
xamount--;
do {
c = fgets(oneword,100,fp1); /* get one line from the file */
if (c != NULL){ for(index = 0;oneword[index] != 0;index++)
if((index < xcol) || (index > xamount))fprintf(fp2,"%c",oneword[index]);
else if(oneword[index] == 10)fprintf(fp2,"\n");
}
if(argc < 2 ){linecount++; printf("\rLine count == %d ",linecount);}
} while (c != NULL); /* repeat until NULL */
fclose(fp1);
fclose(fp2);
} /*-----------------------------------------END---------------------------*/
void directions(void){
printf("\n\n\n\n\n\n\n\n\n\n\n <<< FREEWARE >>>\n\n");
printf(" DELCOL.EXE\n");
printf(" Command line SYNTAX = DELCOL INFILE.EXT OUTFILE.EXT F# L#\n");
printf(" F# = Column number to delete or First column number to delete.\n");
printf(" L# = Column to delete to. If left out, only column F# is deleted.\n");
printf(" If no command line input is entered or it is entered wrong you will be\n");
printf(" prompted for INFILE.EXT OUTFILE.EXT F# L# . So DELCOL.EXE can be run from\n");
printf(" a batch file, command line, or just start the program and enter input.\n");
printf(" SHORT DIRECTIONS\n");
printf(" Enter your file with your ASCII file editor, put the cursor on the first\n");
printf(" column you want deleted, write down the file name & column number the\n");
printf(" cursor is on, then put the cursor on the last colunm you want deleted\n");
printf(" write the number, & start DELCOL. Enter the infilename.ext & outfilename.\n");
printf(" Enter your first del column #, & enter the last del column # , that's it.\n");
printf(" FREEWARE comes with no gaurentees. Get your input column #'s right.\n");
printf(" Press CTRL-C to abort.\n");
printf(" DELCOL.EXE BY Steve Elliott 10-3-92\n\n\n");
}